﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace BaiDuSitemap.DBO
{
    public class DataBase
    {
        public static bool Login(string user,string pass)
        {
            string sql = "select [id] from [QT_AdminUser] where [user]='" + user + "' and [pass]='" + pass + "'";
            DataTable dt = new QT.DBO.OleDBHelper(myDB.connstring).DataTable(sql);
            if (dt.Rows.Count == 1) return true;

            return false;
        }

        public static int UpdatePass(string user, string pass)
        {
            string sql = "update [QT_AdminUser] set [pass]='" + pass + "' where [user]='" + user + "'";
            return new QT.DBO.OleDBHelper(myDB.connstring).ExecuteNonQuery(sql);
        }

        public static DataTable getTabels()
        {
            string sql = "select name from MSysObjects where type=1 and flags=0";
            DataTable dt = new QT.DBO.OleDBHelper(myDB.connstring).DataTable(sql);
            return dt;
        }

        public static DataTable getColumns(string table)
        {
            string sql = "select * from " + table + " where 1=2";
            DataTable dt = new QT.DBO.OleDBHelper(myDB.connstring).DataTable(sql);
            return dt;
        }

        public static DataTable getData(string sql)
        {
            DataTable dt = null;

            dt = new QT.DBO.OleDBHelper(myDB.connstring).DataTable(sql);

            return dt;
        }

        public static int execSQL(string sql)
        {
            return new QT.DBO.OleDBHelper(myDB.connstring).ExecuteNonQuery(sql);
        }
    }
}
